package com.pinganfu.tesla.iwallet;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.TextView;

import com.pinganfu.tesla.iwallet.session.SessionManager;
import com.pinganfu.tesla.iwallet.util.TeslaUtil;
import compinganfu.tesla.iwallet.widget.EditTextWithDel;

public class AddCardActivity extends Activity implements OnClickListener {
	private EditTextWithDel txtCardNo;
	private EditTextWithDel txtMobileNo;
	private SessionManager mSessionManager = SessionManager.getInstance();

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_add_card);

		txtCardNo = (EditTextWithDel) findViewById(R.id.txt_card_no);

		txtMobileNo = (EditTextWithDel) findViewById(R.id.txt_mobile_no);
		Button btnNext = (Button) findViewById(R.id.btn_next);
		txtMobileNo.setActionButton(btnNext);
		txtMobileNo.setText(mSessionManager.getMobileNo());

		btnNext.setOnClickListener(this);

		TextView tvAgreement = (TextView) findViewById(R.id.tv_agreement);
		tvAgreement.setOnClickListener(this);
	}

	@Override
	public void onClick(View v) {
		switch (v.getId()) {
			case R.id.btn_next :
				confirmAddCard();
				break;
			case R.id.tv_agreement :
				TeslaUtil.gotoActivity(this, FastPayAgreementActivity.class);
				break;
		}
	}

	private void confirmAddCard() {
		Intent intent = new Intent(this, AddCardConfirmActivity.class);
		intent.putExtra("cardNo", txtCardNo.getText().toString());
		intent.putExtra("mobileNo", txtMobileNo.getText().toString());
		startActivity(intent);
	}
}
